﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using nMongo.Tests.Entities;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace nMongo.Tests.Repository
{
    public partial class MongoRepositoryTests
    {
        [TestMethod]
        public void GetSingle()
        {
            _MongoRepositoryTestsPrepare.RevertAnyChanges();

            MongoRepository<User> users = new MongoRepository<User>(TestsConfiguration.ConnectionString, TestsConfiguration.DatabaseName);

            IEnumerable<User> users1 = MockGenerator.GenerateList<User>(5);
            string searchName = users1.OrderBy(x => new Guid()).First().Name;
            users.Insert(users1);

            // Assert
            Assert.IsNotNull(users.GetSingle(x => x.Name == searchName));
        }
    }
}
